<?php
/**
 * View problems from past inner_contest and past post 
 *
 * cid : contest id
 */

require('init.php');
$title = "Past Problems";//

require(LIBWWWDIR . '/header.php');

require(LIBWWWDIR . '/forms.php');


if ( !isset($_REQUEST['id']) )		//si no esta definida
	header('Location: index.php');

if ( empty($_REQUEST['id']) )		//si esta definida pero vacia
	header('Location: index.php');

$cid = $_REQUEST['id'];

echo "<h1>Problems</h1>\n\n";
//como son datos del pasado, se busca en db2(bakup)
$problems =exist("cid", $cid, "problem", $conn_db2);
if( $problems[0] > 0 )
{
	echo "<table class=\"list sortable\">\n<thead>\n" .
	"<tr><th scope=\"col\">Problem</th><th scope=\"col\">Statement&nbsp;&nbsp;</th>" .	
	"<th scope=\"col\">Source Code&nbsp;&nbsp;</th><th scope=\"col\">Comments</th>" .
	"</tr></thead>\n<tbody>\n"; 

	for($i=1; $i<=$problems[0]; $i++)
	{
		echo  '<tr><td class="probid" >' .
		( !empty($problems[$i]['color']) ?
		'<img style="background-color: ' . htmlspecialchars($problems[$i]['color']) .
		';" alt="problem colour ' . htmlspecialchars($problems[$i]['color']) .
		'" src="../images/circle.png" /> ' : '' ) . 
		htmlspecialchars($problems[$i]['name']) ."</a></td>". 
		"<td align=\"center\"".show_pdf_db2( $problems[$i]['probid'], $conn_db2)."</td><td align=\"center\">".
		show_link_sc($problems[$i]['probid'],$problems[$i]['cid'],$conn_db2)."</td><td align=\"center\">".
		total_comments($problems[$i]['probid'],$cid,$conn_db2)."</td></tr>";
	}	
}else{
	echo "<p class=\"nodata\">No problems defined</p>\n\n";
}
echo "</tbody>\n</table>\n\n";

require(LIBWWWDIR . '/footer.php');
?>
